﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.ServiceModel;
using System.Text;
using Common.Logging;
using Jackie.Utility.Notify.Domain;
using Jackie.Utility.Notify.Services;
using Jackie.Utility.Notify.Services.Manager;

namespace Jackie.Utility.Notify.Server
{
    class Program
    {
        static void Main(string[] args)
        {
            var logger = LogManager.GetLogger("Service Host");
            ServiceHost publishHost = null;
            ServiceHost subscribeHost = null;

            try
            {
                logger.Info("start new publish service host and open it!");
                publishHost = new ServiceHost(typeof(PublishService));
                publishHost.Open();
                logger.Info("publish host opened!");

                logger.Info("start new subscribe service host and open it!");
                subscribeHost = new ServiceHost(typeof(SubscribeService));
                subscribeHost.Open();
                logger.Info("subscribe host opened!");
            }
            catch (Exception ex)
            {
                logger.Error("error!", ex);
            }



            logger.Info("input exit to close the host");

            while (true)
            {
                var order = Console.ReadLine();
                if (order.Equals("exit"))
                    break;
            }

            logger.Info("start close host!");
            publishHost.Close();
            subscribeHost.Close();
            logger.Info("host closed!");
        }
    }
}
